#include "Segmentation.h"

Segmentation::Segmentation(CVImage& image,int smooth)
{
	this->_image=&image;
	this->smoothness=smooth;
}

Segmentation::~Segmentation()
{

}

inline double Segmentation::DataEnergy(uint x,uint y,int label)
{
	double ip=(double)(((uint) _image->Pixel(x,y,0))&(_image->ibits()));
	return (double)(ip-label)*(ip-label)/(1<<_image->depth())/(1<<_image->depth());
}

inline double Segmentation::SmoothEnergy(int lp,int label)
{
	double lp1=(double)lp;
	return smoothness*fabs(lp1-label)/(1<<_image->depth())/(1<<_image->depth());
}
